package com.levy.contronller.lamdaTest;

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

public class PredicateTest {

    private static List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

    public static void main(String[] args) {
        PredicateTest predicateTest = new PredicateTest();
        predicateTest.conditionFilter(list, o -> o > 5);
        System.out.println("---------------------------------");
        predicateTest.conditionFilter2(list, o -> o > 5, o -> o % 2 == 0);
        System.out.println("---------------------------------");
        boolean test = predicateTest.isEqual("ddd").test("fff");
        System.out.println(test);
    }


    public void conditionFilter(List<Integer> list, Predicate<Integer> predicate) {
        list.stream().filter(i -> predicate.test(i)).forEach(o -> System.out.println(o));
    }

    public void conditionFilter2(List<Integer> list, Predicate<Integer> p1, Predicate<Integer> p2) {
        list.stream().filter(i -> p1.and(p2).test(i)).forEach(o -> System.out.println(o));
    }

    public Predicate<String> isEqual(Object o){
            return Predicate.isEqual(o);
    }
}
